package com.danco.training.zaneuskaya.property;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.log4j.Logger;

public class DBPropertyReader {
	private Properties props;
	private InputStream input;
	private static String filename = "database.properties";
	private static DBPropertyReader dbPropertyReaderInstance;
	
	private static final Logger logger = Logger.getLogger(DBPropertyReader.class);
	
	private DBPropertyReader(){
			
		props = new Properties();
	   	
		input = getClass().getClassLoader().getResourceAsStream(filename);
		try {
			props.load(input);
		} catch (IOException e) {
			logger.error(e.getMessage(), e);
		}
			
	 }

	public static DBPropertyReader getDBPropertyReaderInstance() {
		if (dbPropertyReaderInstance == null){
			dbPropertyReaderInstance = new DBPropertyReader();
		}
		return dbPropertyReaderInstance;
	}

	public Properties getProps() {
		 try {

			input.close();
		} catch (IOException e) {
			logger.error(e.getMessage(), e);
		}
		
		return props;
	}


	

}
